﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problema1_AbstractFactory_Singleton_ObjectPool
{
    public class ClientPersoanaFizica : Client
    {
        public ClientPersoanaFizica(Factory factory)
        {
            m_strNume = "";
            m_strVarsta = "";
            m_lstListaMasini = new List<Masina>();
            m_ftrFactory = factory;
        }

        public override string getNume()
        {
            return this.m_strNume;
        }
        public override void setNume(string Nume)
        {
            m_strNume = Nume;
        }

        public override string getVarsta()
        {
            return this.m_strVarsta;
        }

        public override void setVarsta(string Varsta)
        {
            m_strVarsta = Varsta;
        }

        //public override void addMasini(Masina masina)
        //{
        //    this.m_lstListaMasini.Add(masina);
        //}
        //public override void delMasini(int i)
        //{
        //    this.m_lstListaMasini.Remove(m_lstListaMasini[i]);
        //}
        public override void afisareMasini()
        {
            for (int j = 0; j < m_lstListaMasini.Count();j++ )
            {
                if (m_lstListaMasini[j] != null)
                {
                    Console.WriteLine("-----------");
                    Console.WriteLine(m_lstListaMasini[j].getTip());
                    //Console.WriteLine(m_lstListaMasini[j].getSerie());
                    Console.WriteLine(m_lstListaMasini[j].getCuloare());
                    Console.WriteLine(m_lstListaMasini[j].getTransmisie());
                    Console.WriteLine(m_lstListaMasini[j].getMotorizare());
                    Console.WriteLine(m_lstListaMasini[j].getClimatizare());
                    Console.WriteLine(m_lstListaMasini[j].getTapiterie());
                }
            }
        }
        public override void comandaMasina(int tip, int cul, int trs, int clm, int tap)
        {
            Masina m = this.m_ftrFactory.comandaMasina(tip, cul, trs, clm, tap);
            this.m_lstListaMasini.Add(m);
        }
        public override void stergeMasina(int nr)
        {
            if (nr == m_lstListaMasini.Count-1)
            {
                m_lstListaMasini[nr]=null;
            }
            if (nr > m_lstListaMasini.Count - 1)
            {
                Console.WriteLine("Error!");
            }
            if (nr < m_lstListaMasini.Count - 1)
            {
                m_lstListaMasini[nr] = m_lstListaMasini[m_lstListaMasini.Count - 1];
                m_lstListaMasini[m_lstListaMasini.Count - 1] = null;
            }
        }
    }
}
